package com.refusea.train.domain.helper

import com.refusea.train.config.mvc.WebSession
import com.refusea.train.domain.cache.SchoolCache
import com.refusea.train.domain.entity.User
import org.springframework.stereotype.Component

/**
 * @author Zhang Yan 2024/3/31
 **/
@Component
class UserinfoHelper(
    private val schoolCache: SchoolCache,
) {
    fun userinfo(): User? {
        val user = WebSession.user()
        if (user.school == null) {
            user.school = schoolCache.get(user.schoolId)?.name
        }
        return user
    }
}
